/*
 * Copyright (c) by Medtronic, Inc., 2012
 * $HeadURL: http://build-tool.googlecode.com/svn/trunk/BuildTool/quals/main_fw/code/shared_app/bootup_main_shared.h $
 * $Revision: 71 $
 * $Date: 2013-08-12 13:43:22 +0000 (Mon, 12 Aug 2013) $
 */
#ifndef BOOTUP_MAIN_SHARED_H_
#define BOOTUP_MAIN_SHARED_H_

typedef struct
{
    __packed uint16_t por_info_crc;
    uint8_t cumulative_por_count;
    uint8_t flash_ecc_por_count;
} POR_COUNTS_T;

// Saves information on which assert failed.
typedef struct
{
	int line; // line number of assert that failed
	const char *file; // Pointer to file name containing assert that failed.
} ASSERT_REASON_T;

// This structure needs to be aligned in memory to start on a word boundary.
// The final values for these variables are inserted by the build tools.
typedef struct
{
    uint8_t copyright_cpu[34];
    uint8_t date_time_stamp[30];

    uint8_t base_major_rev;
    uint8_t base_minor_rev;
    uint8_t cron_major_rev;
    uint8_t cron_minor_rev;

    // We want the ROM and flash build info layout to be the same, so
    // we'll reserve space for the flash feature ID even though it's
    // not needed for ROM.
    uint8_t flashfeature_major_id;
    uint8_t flashfeature_minor_id;

    // Needed to align code_crc_addr on word boundary.
    uint16_t rev_info_reserved_for_future_use;

    // A post-link build tool will add the address of the code CRC,
    // which resides immediately after the last code byte.
    uint32_t code_crc_addr;
}BUILD_INFO_TYPE;


// Define the size of the temp stack that's used by boot-up. This
// temp stack is also used by back-up and main code POR processing
// until the normal stack has been copied to external SRAM and
// cleared.
#define TEMP_STACK_SIZE (32)


// Define the size of the utility area. This area must be the
// same size and at the same location in both bootup and main code.
#define BOOTUP_UTILITY_AREA_SIZE (256)


/* Codes used when forcing a POR. */
#define FIRM_NO_ID_RST        (UINT8_C(0x01))
#define FIRM_CRC_ERR_RST      (UINT8_C(0x02))
#define FIRM_HARDFAULT_RST    (UINT8_C(0x03))
#define FIRM_MEMMANAGE_RST    (UINT8_C(0x04))
#define FIRM_BUSFAULT_RST     (UINT8_C(0x05))
#define FIRM_USAGEFAULT_RST   (UINT8_C(0x06))
#define FIRM_ILLEGALCALL_RST  (UINT8_C(0x07))
#define FIRM_MEM_TEST_RST     (UINT8_C(0x08))
#define FIRM_SCHEDULER_RST    (UINT8_C(0x09))   // Scheduler POR (feature not-responding)
#define FIRM_EVENT_BUF_RST    (UINT8_C(0x0A))
#define FIRM_EDC_RST          (UINT8_C(0x0B))
#define FIRM_ADCRF_RW_RST     (UINT8_C(0x0C))   // ADC rapid fire RAMWARE in unexpected state
#define FIRM_NMI_RST          (UINT8_C(0x0D))
#define SYSTICK_FAULT_RST     (UINT8_C(0x0E))
#define FIRM_ASSERT_RST       (UINT8_C(0x0F))
#define FIRM_DEBUG_RST        (UINT8_C(0x10))
#define FIRM_SVC_RST          (UINT8_C(0x11))
#define FIRM_BIST_RST         (UINT8_C(0x12))   // BIST initiated POR  (UNUSED)


#endif /* BOOTUP_MAIN_SHARED_H_ */
